//
//  WorksCell.m
//  XDBaseFrameWork
//
//  Created by XD-XY on 9/20/14.
//  Copyright (c) 2014 XD-XY. All rights reserved.
//

#import "WorksCell.h"

@implementation WorksCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.backgroundColor = [UIColor whiteColor];
        [self makeViews];
    }
    return self;
}

-(void)makeViews
{
    self.imageIV = [[UIImageView alloc] initWithFrame:self.bounds];
    _imageIV.backgroundColor = UIColorFromRGB(0xfcf2d7);
    
//    self.footIV = [[UIImageView alloc] initWithFrame:CGRectMake(0, self.frame.size.height-25, self.frame.size.width, 40)];
//    _footIV.backgroundColor = [UIColor whiteColor];
//    _footIV.image = LOADIMAGE(@"works_grayentry@2x");
    
    
//    _imageIV.contentMode = UIViewContentModeScaleAspectFit;
//    
//    _imageIV.layer.rasterizationScale = [UIScreen mainScreen].scale;
//    _imageIV.layer.shouldRasterize   = YES;
//    _imageIV.clipsToBounds = YES;
//    _imageIV.contentMode = UIViewContentModeScaleAspectFill;//跟微信一样 填充
    
    self.descriptionLB = [UILabel initLabelText:@"" andRect:CGRectMake(5, 0, 145, 25) andBackGroudColor:[UIColor clearColor] andTextFont:[UIFont systemFontOfSize:15] andTextColor:UIColorFromRGB(0x565656) andTextAlignment:NSTextAlignmentLeft];
    _descriptionLB.numberOfLines = 0;
    
    

    self.emplNameLB = [UILabel initLabelText:@"" andRect:CGRectMake(5, 25, 70, 15) andBackGroudColor:[UIColor clearColor] andTextFont:[UIFont systemFontOfSize:13] andTextColor:UIColorFromRGB(0x9d9d9d) andTextAlignment:NSTextAlignmentLeft];
    
    self.numberLB = [UILabel initLabelText:@"" andRect:CGRectMake(75, 25-2, 70, 15) andBackGroudColor:[UIColor clearColor] andTextFont:[UIFont systemFontOfSize:13] andTextColor:UIColorFromRGB(0x9d9d9d) andTextAlignment:NSTextAlignmentRight];
    
    self.levelLB = [UILabel initLabelText:@"" andRect:CGRectMake(75, 40, 70, 15) andBackGroudColor:[UIColor clearColor] andTextFont:[UIFont systemFontOfSize:11] andTextColor:UIColorFromRGB(0x9d9d9d) andTextAlignment:NSTextAlignmentLeft];
    
    self.heartIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"grayHeart"]];
    [self addSubview:_heartIV];
    
    [self addSubview:_imageIV];
    [self addSubview:_numberLB];
    [self addSubview:_emplNameLB];
    [self addSubview:_descriptionLB];
    [self addSubview:_levelLB];
    
    _footIV.hidden = YES;
    
    _shortXuXian = [[UIImageView alloc] initWithFrame:CGRectMake(85, height_y(_descriptionLB)+3, 226, 1)];
    _shortXuXian.image = [UIImage imageNamed:@"xuxian_mostShort"];
//    _shortXuXian.backgroundColor = [UIColor blackColor];
    [self addSubview:_shortXuXian];
    
    self.layer.masksToBounds = YES;
    self.layer.cornerRadius = 3;
}

-(void)setDataDict:(NSDictionary *)dataDict
{
    self.imageIV.frame = CGRectMake(0, 0, [dataDict[@"PhotoWidth"] floatValue]/2.0f, [dataDict[@"PhotoHeight"] floatValue]/2.0f);
//    self.footIV.frame = CGRectMake(0, [dataDict[@"PhotoHeight"] floatValue]/2.0f, self.frame.size.width, 40);
    if(_dataDict){
        _dataDict = nil;
    }
    _dataDict = dataDict;
    [self.imageIV sd_setImageWithURL:[NSURL URLWithString:self.dataDict[@"FilePath"]] placeholderImage:ivDetaultImg];
    
    _descriptionLB.frame = CGRectMake(10, height_y(_imageIV)+5, 140, 15);
    _descriptionLB.text = _dataDict[@"WDesc"];
    [_descriptionLB sizeToFit];
    if (_descriptionLB.frame.size.height > 55) {
        _descriptionLB.frame = CGRectMake(10, height_y(_imageIV)+5, 140, 55);
    }
    
    _shortXuXian.frame = CGRectMake(10, height_y(_descriptionLB)+2, 124, .5f);
    
    
    _numberLB.text = _dataDict[@"CollectionCount"];
    [_numberLB sizeToFit];
    _numberLB.frame = CGRectMake(135-_numberLB.bounds.size.width, height_y(_shortXuXian)+7, _numberLB.bounds.size.width, _numberLB.bounds.size.height);
    
    _heartIV.frame = CGRectMake(_numberLB.frame.origin.x-12, height_y(_shortXuXian)+11, 10, 8);

    
    _emplNameLB.frame = CGRectMake(10, height_y(_descriptionLB)+5, 65, 15);
    _emplNameLB.text = [NSString stringWithFormat:@"%@",_dataDict[@"EmplName"]];
    
//    _priceLB.frame = CGRectMake(70, height_y(_descriptionLB)+5, 70, 15);
//    _priceLB.text = [NSString stringWithFormat:@"￥%@起",_dataDict[@"Price"]];
    
    _levelLB.frame = CGRectMake(10, height_y(_emplNameLB)+2, 100, 15);
    _levelLB.text = _dataDict[@"LevelName"];    
    
    _footIV.hidden =NO;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
